import Vue from 'vue'
import Router from 'vue-router'
import Login from '../pages/login/login'
import Common from '../pages/common/index'

//首页
import Home from '../pages/home/home'  //首页
import SkuList from '../pages/sku/skuList'  //SKU商品列表
import SkuAdd from '../pages/sku/skuAdd'  //SKU新增
import SkuDetail from '../pages/sku/skuDetail'  //SKU详情
import SkuPrint from '../pages/sku/skuPrint'  //SKU详情
import SkuProperty from '../pages/sku/skuProperty'  //SKU属性
import GoodsEntry from '../pages/goods/goodsEntry'  //商品录入

import FactoryExitList from '../pages/factory/factoryExitList/index'  //酒厂出库单
import outgoingOrders from '../pages/factory/factoryExitList/outgoingOrders'//酒厂出库单详情明细
import outgoingOrdersDetail from '../pages/factory/factoryExitList/outgoingOrdersDetail' //酒厂出库单详情明细详情
import factoryExitListDetail from '../pages/factory/factoryExitList/factoryExitListDetail'//酒厂出库单详情
import FactoryStoreTable from '../pages/factory/factoryStoreTable/index'  //酒厂库存统计表
import FrozenStock from '../pages/factory/factoryStoreTable/frozenStock'//库存统计冻结表明细
import frozenStockDetail from '../pages/factory/factoryStoreTable/frozenStockDetail' //库存冻结详情
import SalesDetail from '../pages/factory/factoryStoreTable/salesDetail'//库存统计可销售明细
import merchantability from '../pages/factory/factoryStoreTable/merchantability'//库存统计可销售详情
import outMangement from '../pages/factory/factoryStoreTable/outMangement' //可出库详情
import Winecellar from '../pages/cellar/Winecellar/index'  //酒窖入库单
import WinecellarDetail from '../pages/cellar/Winecellar/WinecellarDetail'//酒窖入库明细
import warehousingDetails from '../pages/cellar/Winecellar/warehousingDetails'//酒窖入库明细详情
import orderDetails from '../pages/cellar/Winecellar/orderDetails'//酒窖入库订单明细
import Selfraisedinventory from '../pages/cellar/Selfraisedinventory/index'  //酒窖自提出库单
import SelfraisedinventoryDetail from '../pages/cellar/Selfraisedinventory/SelfraisedinventoryDetail'//自提出库单详情
import makeOver from '../pages/cellar/makeOver/index'  //酒窖转让出库单
import makeOverDetail from '../pages/cellar/makeOver/makeOverDetail'//转让出库单明细
import commonCellar from '../pages/cellar/commonCellar/index'//出库明细
import transferOut from '../pages/cellar/commonCellar/transferOut'//转让出库
import selfExtraction from '../pages/cellar/commonCellar/selfExtraction'//自提
import CellarStoreTable from '../pages/cellar/cellarStoreTable/index'  //酒窖库存统计表
import cellarfrozenStock from '../pages/cellar/cellarStoreTable/cellarfrozenStock'//酒窖冻结
import storageofWine from '../pages/cellar/cellarStoreTable/storageofWine' //酒窖酒藏
import storageofWineDetail from '../pages/cellar/cellarStoreTable/storageofWineDetail' //酒窖酒藏详情
import cellerOut from '../pages/cellar/cellarStoreTable/cellerOut'//酒窖库存统计出库详情
import cellarIn from '../pages/cellar/cellarStoreTable/cellarIn'//酒窖库存统计入库详情
import OrderSettle from '../pages/funds/orderSettle'  //订单结算
import OrderDetail from '../pages/funds/orderDetail'  //订单结算详情
import TransferSettle from '../pages/funds/transferSettle'  //转让超时结算
import TransferDetail from '../pages/funds/transferDetail'  //转让超时结算详情
import FundsManage from '../pages/funds/fundsManage'  //仓储费管理
import TakeDetail from '../pages/funds/takeDetail'  //仓储费管理详情
import FundsDetail from '../pages/funds/fundsDetail'  //资金明细
import AccountSet from '../pages/funds/accountSet'  //对公账户配置
import TraceInfo from '../pages/trace/traceInfo'  //溯源信息
import TraceDetail from '../pages/trace/traceDetail'  //溯源信息详情
import goodsEntryDetail from '../pages/goods/detail' //商品录入详情页
import WarehouseManagement from '../pages/factory/warehouseManagements/index'//酒厂仓库
import WarehouseDetails from '../pages/factory/warehouseManagements/detail' //仓库详情页
import cargoDetails from '../pages/factory/warehouseManagements/cargodetails' //酒厂货位详情页
import cellarManagement from '../pages/cellar/cellarManagement/index'//酒窖仓库
import cellaDetails from '../pages/cellar/cellarManagement/detail' //酒窖仓库详情页
import jccargoDetails from '../pages/cellar/cellarManagement/cargoDetails'// 酒窖货位详情页
import FactoryEntryList from '../pages/factory/factoryEntryList/index' //酒厂入库单
import FactoryEntryListDetail from '../pages/factory/factoryEntryList/factoryEntryListDetail' //酒厂入库明细
import Outofthewarehouse from '../pages/factory/factoryEntryList/Outofthewarehouse'//转出入库明细
import Detailsofnewwine from '../pages/factory/factoryEntryList/detailsofnewwine'//新酒入库明细
import DistilleryInventory from '../pages/factory/distilleryInventory/index'//酒厂盘点记录
import beginCheck from '../pages/factory/distilleryInventory/beginCheck/index'//酒厂开始盘点
import beginCheckdetails from '../pages/factory/distilleryInventory/beginCheck/details'//酒厂开始盘点详情
import physicalCount from '../pages/factory/distilleryInventory/physicalCount'//酒厂盘点记录
import cellarstatistics from '../pages/cellar/cellarstatistics/index'//酒窖盘点记录
import cellBeginCheck from '../pages/cellar/cellarstatistics/cellBeginCheck/index'//酒窖开始盘点
import cellBeginCheckdetails from '../pages/cellar/cellarstatistics/cellBeginCheck/details'//酒窖开始盘点详情
import cellphysicalCount from '../pages/cellar/cellarstatistics/cellphysicalCount' //酒窖保存盘点
import alloCation from '../pages/factory/alloCation/index' //酒厂调拨单
import allCationdetails from '../pages/factory/alloCation/details' //酒厂调拨记录
import factphydetail from '../pages/factory/distilleryInventory/factphydetail' //酒厂盘点详情
import cellCationdetail from '../pages/cellar/cellCation/details' //酒厂盘点详情
import cellCation from '../pages/cellar/cellCation/index' //酒厂盘点详情
import cellphydetail from '../pages/cellar/cellarstatistics/cellphydetail' //酒厂完成盘点详情
Vue.use(Router)
var router = new Router({
  routes: [
    {
      path: '/login',
      name: '登录',
      component: Login,
      meta: {
        title: '用户登录'
      }
    },
    {
      path: "*",
      name: '首页',
      redirect: '/home'
    },
    {
      path: '/',
      component: Common,
      name: 'common',
      redirect: '/home',
      children: [
        {
          path: '/home',
          name: '数据概览',
          component: Home,
          meta: {
            title:'数据概览',
            primaryTitle: '首页'
          }
        },
        {
          path: '/skuList',
          name: 'SKU商品列表',
          component: SkuList,
          meta: {
            title:'SKU商品列表',
            primaryTitle: 'SKU管理'
          }
        },
        {
          path: '/skuProperty',
          name: 'SKU属性',
          component: SkuProperty,
          meta: {
            title:'SKU属性',
            primaryTitle: 'SKU管理'
          }
        },
        {
          path: '/skuAdd',
          name: 'SKU新增',
          component: SkuAdd,
          meta: {
            title:'SKU商品列表',
            primaryTitle: 'SKU管理'
          }
        },
        {
          path: '/skuDetail',
          name: 'SKU详情',
          component: SkuDetail,
          meta: {
            title:'SKU商品列表',
            primaryTitle: 'SKU管理'
          }
        },
        {
          path: '/skuPrint',
          name: '商品ID打印',
          component: SkuPrint,
          meta: {
            title:'SKU商品列表',
            primaryTitle: 'SKU管理'
          }
        },
        {
          path: '/goodsEntry',
          name: '商品录入',
          component: GoodsEntry,
          meta: {
            title:'商品录入',
            primaryTitle: '商品录入管理'
          }
        },
        {
          path: '/goodsEntry/detail',
          name: '商品录入详情页',
          component: goodsEntryDetail,
          meta: {
            title:'商品录入',
            primaryTitle: '商品录入管理'
          }
        },
        {
          path: '/factoryEntryList',
          name: '酒厂入库单',
          component: FactoryEntryList,
          meta: {
            title:'酒厂入库单',
            primaryTitle: '酒厂管理'
          }
        },
        {
          path: '/FactoryEntryListDetail/:sku',
          name: '酒厂入库单明细',
          component: FactoryEntryListDetail,
          meta: {
            title:'酒厂入库单',
            primaryTitle: '酒厂管理'
          }
        },
        {
          path: '/Outofthewarehouse/:id',
          name: '转让入库明细',
          component: Outofthewarehouse,
          meta: {
            title:'酒厂入库单',
            primaryTitle: '酒厂入库单明细'
          }
        },
        {
          path: '/detailsofnewwine/:id',
          name: '新酒入库明细',
          component: Detailsofnewwine,
          meta: {
            title:'酒厂入库单',
            primaryTitle: '酒厂入库单明细'
          }
        },
        {
          path: '/factoryExitList',
          name: '酒厂出库单',
          component: FactoryExitList,
          meta: {
            title:'酒厂出库单',
            primaryTitle: '酒厂管理'
          }
        },
        {
          path: '/factoryExitListDetail/:id/:proId',
          name: '酒厂出库单详情',
          component: factoryExitListDetail,
          meta: {
            title:'酒厂出库单',
            primaryTitle: '酒厂出库单详情'
          }
        },
        {
          path: '/outgoingOrders',
          name: '出库单明细',
          component: outgoingOrders,
          meta: {
            title:'酒厂出库单',
            primaryTitle: '酒厂管理'
          }
        },
        {
          path: '/outgoingOrdersDetail/:id/:proId',
          name: '出库单订单详情',
          component: outgoingOrdersDetail,
          meta: {
            title:'酒厂出库单',
            primaryTitle: '出库单明细'
          }
        },
        {
          path: '/factoryStoreTable',
          name: '酒厂库存统计表',
          component: FactoryStoreTable,
          meta: {
            title:'酒厂库存统计表',
            primaryTitle: '酒厂管理'
          }
        },
        {
          path: '/frozenStock',
          name: '入库明细表',
          component: FrozenStock,
          meta: {
            title:'酒厂库存统计表',
            primaryTitle: '商品库存分布'
          }
        },
        {
          path: '/frozenStockDetail/:id',
          name: '冻结明细详情',
          component: frozenStockDetail,
          meta: {
            title:'酒厂库存统计表',
            primaryTitle: '商品库存分布'
          }
        },
        {
          path: '/SalesDetail',
          name: '可销售库存明细',
          component: SalesDetail,
          meta: {
            title:'酒厂库存统计表',
            primaryTitle: '商品库存分布'
          }
        },
        {
          path: '/merchantability/:id',
          name: '可销售库存详情',
          component: merchantability,
          meta: {
            title:'酒厂库存统计表',
            primaryTitle: '商品库存分布'
          }
        },{
          path: '/outMangement/:id',
          name: '出库详情',
          component: outMangement,
          meta: {
            title:'酒厂库存统计表',
            primaryTitle: '商品库存分布'
          }
        },
        {
          path: '/warehouseManagement',
          name: '酒厂仓库管理',
          component: WarehouseManagement,
          meta: {
            title:'酒厂仓库管理',
            primaryTitle: '酒厂管理'
          }
        },
        {
          path: '/warehouseManagement/:id',
          name: '酒厂货位管理',
          component: WarehouseDetails,
          meta: {
            title:'酒厂仓库管理',
            primaryTitle: '酒厂管理'
          }
        },
        {
          path: '/warehouseManagement/:id/:proId',
          name: '货位详情页',
          component: cargoDetails,
          meta: {
            title:'酒厂仓库管理',
            primaryTitle: '货位管理',
            // zname:'货位详情页'
          }
        },
        {
          path: '/DistilleryInventory',
          name: '酒厂盘点记录',
          component: DistilleryInventory,
          meta: {
            title:'酒厂盘点记录',
            primaryTitle: '酒厂管理'
          }
        },
        {
          path: '/beginCheck',
          name: '开始盘点',
          component: beginCheck,
          meta: {
            title:'酒厂盘点记录',
            primaryTitle: '酒厂管理'
          }
        },{
          path: '/beginCheckdetails',
          name: '开始盘点详情页',
          component: beginCheckdetails,
          meta: {
            title:'酒厂盘点记录',
            primaryTitle: '开始盘点'
          }
        },{
          path: '/FactoryphysicalCount',
          name: '完成盘点',
          component: physicalCount,
          meta: {
            title:'酒厂盘点记录',
            primaryTitle: '酒厂管理'
          }
        },{
          path: '/factphydetail',
          name: '完成盘点详情',
          component: factphydetail,
          meta: {
            title:'酒厂盘点记录',
            primaryTitle: '酒厂管理'
          }
        },{
          path: '/alloCation',
          name: '酒厂调拨记录',
          component: alloCation,
          meta: {
            title:'酒厂调拨记录',
            primaryTitle: '酒厂管理'
          }
        },{
          path: '/allCationdetails',
          name: '酒厂调拨记录详情',
          component: allCationdetails,
          meta: {
            title:'酒厂调拨记录',
            primaryTitle: '酒厂管理'
          }
        },
        {
          path: '/Winecellar',
          name: '入库单',
          component: Winecellar,
          meta: {
            title:'入库单',
            primaryTitle: '酒窖管理'
          }
        },
        {
          path: '/orderDetails/:id',
          name: '入库单订单详情',
          component: orderDetails,
          meta: {
            title:'入库单',
            primaryTitle: '酒窖管理'
          }
        },
        {
          path: '/WinecellarDetail',
          name: '入库单明细',
          component: WinecellarDetail,
          meta: {
            title:'入库单',
            primaryTitle: '酒窖管理'
          }
        },
        {
          path: '/warehousingDetails/:id',
          name: '入库单明细详情',
          component: warehousingDetails,
          meta: {
            title:'入库单',
            primaryTitle: '入库单明细'
          }
        },
        
        {
          path: '/Selfraisedinventory',
          name: '自提出库单',
          component: Selfraisedinventory,
          meta: {
            title:'自提出库单',
            primaryTitle: '酒窖管理',
            ptype:0
          }
        },
        {
          path: '/SelfraisedinventoryDetail/:id',
          name: '自提出库单明细',
          component: SelfraisedinventoryDetail,
          meta: {
            title:'自提出库单',
            primaryTitle: '酒窖管理'
          }
        },
        {
          path: '/makeOver',
          name: '转让出库单',
          component: makeOver,
          meta: {
            title:'转让出库单',
            primaryTitle: '酒窖管理',
            ptype:1
          }
        },
        {
          path: '/makeOverDetail/:id',
          name: '转让出库单明细',
          component: makeOverDetail,
          meta: {
            title:'转让出库单',
            primaryTitle: '酒窖管理'
          }
        },
        {
          path: '/commonCellar/:ptype',
          name: '出库明细',
          component: commonCellar,
          meta: {
            title:'出库明细',
            primaryTitle: '酒窖管理'
          }
        },
        {
          path: '/transferOut/:id',
          name: '转让出库单详情',
          component: transferOut,
          meta: {
            title:'转让出库单',
            primaryTitle: '酒窖管理'
          }
        },
        {
          path: '/selfExtraction/:id',
          name: '自提出库单详情',
          component: selfExtraction,
          meta: {
            title:'自提出库单',
            primaryTitle: '酒窖管理',
            
          }
        },
        {
          path: '/cellarStoreTable',
          name: '库存统计表',
          component: CellarStoreTable,
          meta: {
            title:'库存统计表',
            primaryTitle: '酒窖管理',
            ptype:2
          }
        },
        {
          path: '/cellerOut/:id',
          name: '库存统计表出库详情',
          component: cellerOut,
          meta: {
            title:'库存统计表',
            primaryTitle: '酒窖管理',
            ptype:2
          }
        },
        {
          path: '/cellarIn/:id',
          name: '库存统计表入库详情',
          component: cellarIn,
          meta: {
            title:'库存统计表',
            primaryTitle: '酒窖管理',
            ptype:2
          }
        },
        {
          path: '/storageofWine',
          name: '窖藏明细',
          component: storageofWine,
          meta: {
            title:'库存统计表',
            primaryTitle: '酒窖管理'
          }
        },
        {
          path: '/storageofWineDetail/:id',
          name: '窖藏明细详情',
          component: storageofWineDetail,
          meta: {
            title:'库存统计表',
            primaryTitle: '窖藏明细'
          }
        },
        {
          path: '/cellarfrozenStock',
          name: '冻结明细',
          component: cellarfrozenStock,
          meta: {
            title:'库存统计表',
            primaryTitle: '酒窖管理'
          }
        },
        {
          path: '/cellarManagement',
          name: '仓库管理',
          component: cellarManagement,
          meta: {
            title:'仓库管理',
            primaryTitle: '酒窖管理'
          }
        },
        {
          path: '/cellarManagement/:id',
          name: '酒窖货位管理',
          component: cellaDetails,
          meta: {
            title:'仓库管理',
            primaryTitle: '酒窖管理'
          }
        },
        {
          path: '/cellarManagement/:id/:proId/:areaId',
          name: '货位管理详情页',
          component: jccargoDetails,
          meta: {
            title:'仓库管理',
            primaryTitle: '酒窖管理'
          }
        },{
          path: '/cellarstatistics',
          name: '盘点记录',
          component: cellarstatistics,
          meta: {
            title:'盘点记录',
            primaryTitle: '酒窖管理'
          }
        },{
          path: '/cellBeginCheck',
          name: '酒窖开始盘点',
          component: cellBeginCheck,
          meta: {
            title:'盘点记录',
            primaryTitle: '酒窖管理'
          }
        },{
          path: '/cellBeginCheckdetails',
          name: '开始盘点详情',
          component: cellBeginCheckdetails,
          meta: {
            title:'盘点记录',
            primaryTitle: '开始盘点'
          }
        },
        {
          path: '/cellphysicalCount',
          name: '酒窖完成盘点',
          component: cellphysicalCount,
          meta: {
            title:'盘点记录',
            primaryTitle: '酒窖管理'
          }
        },
        {
          path: '/orderSettle',
          name: '订单结算',
          component: OrderSettle,
          meta: {
            title:'盘点记录',
            title:'订单结算',
            primaryTitle: '资金管理'
          }
        },
        {
          path: '/orderDetail',
          name: '订单结算详情',
          component: OrderDetail,
          meta: {
            title:'订单结算',
            primaryTitle: '资金管理'
          }
        },
        {
          path: '/transferSettle',
          name: '转让超时结算',
          component: TransferSettle,
          meta: {
            title:'转让超时结算',
            primaryTitle: '资金管理'
          }
        },
        {
          path: '/transferDetail',
          name: '转让超时结算详情',
          component: TransferDetail,
          meta: {
            title:'转让超时结算',
            primaryTitle: '资金管理'
          }
        },
        {
          path: '/fundsManage',
          name: '仓储费管理',
          component: FundsManage,
          meta: {
            title:'仓储费管理',
            primaryTitle: '资金管理'
          }
        },
        {
          path: '/takeDetail',
          name: '仓储费管理详情',
          component: TakeDetail,
          meta: {
            title:'仓储费管理',
            primaryTitle: '资金管理'
          }
        },
        {
          path: '/fundsDetail',
          name: '资金明细',
          component: FundsDetail,
          meta: {
            title:'资金明细',
            primaryTitle: '资金管理'
          }
        },
        {
          path: '/accountSet',
          name: '对公账户配置',
          component: AccountSet,
          meta: {
            title:'对公账户配置',
            primaryTitle: '资金管理'
          }
        },
        {
          path: '/traceInfo',
          name: '溯源信息',
          component: TraceInfo,
          meta: {
            title:'溯源信息',
            primaryTitle: '溯源管理'
          }
        },
        {
          path: '/traceDetail',
          name: '溯源信息详情',
          component: TraceDetail,
          meta: {
            title:'溯源信息',
            primaryTitle: '溯源管理'
          }
        },{
          path: '/cellCation',
          name: '调拨记录',
          component: cellCation,
          meta: {
            title:'调拨记录',
            primaryTitle: '酒窖管理'
          }
        },{
          path: '/cellCationdetail',
          name: '调拨记录详情',
          component: cellCationdetail,
          meta: {
            title:'调拨记录',
            primaryTitle: '酒窖管理'
          }
        },{
          path: '/cellphydetail',
          name: '盘点完成详情',
          component: cellphydetail,
          meta: {
            title:'盘点记录',
            primaryTitle: '酒窖管理'
          }
        }
      ]
    }
  ]
})

router.beforeEach((to, from, next) => {
  document.title = to.name;
  if (to.query.token) {
    localStorage.setItem('token', to.query.token);
  }
  if (localStorage.getItem('token')) {
    if (to.path == "/login") {
      next('/')
    } else {
      next();
    }
  } else {
    if (to.path == "/login") {
      next();
    } else {
      next('/login');
    }
  }
});
export default router;